package com.treasure.mall.zbqmallapi.vo.live;

import com.treasure.mall.biz.entity.live.LiveRoomPO;
import com.treasure.mall.biz.entity.live.LiveSessionPO;
import com.treasure.mall.biz.service.core.live.LiveSessionService;
import com.treasure.mall.biz.vo.BaseVO;
import com.treasure.mall.zbq.common.ienum.live.LiveEnums;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 *
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.zbqmallapi.vo.live
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/6/13 19:40
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * Copyright 2019-2022 com.treasure.mall.zbqmallapi.vo.live Inc. All rights reserved.
 */
@Data
@NoArgsConstructor
public class LiveRoomVO implements BaseVO {
    private static final long serialVersionUID = 2382019259409432701L;

    /**
     * 房间ID
     */
    private Long id;
    /**
     * 所属商家
     */
    private Long merchantId;

    private boolean enableContact;

    private Long cateId;
    /**
     * 直播间数据
     */
    private LiveRoomDataVO data;
    /**
     * 排序
     */
    private Integer orderWeight = 0;

    /**
     * 审核状态{@link LiveEnums.AuditStatus}
     */
    private LiveEnums.AuditStatus auditStatus;
    private boolean enabled;
    /**
     * 理由
     */
    private String reason;
    /**
     * 当前的直播场次（可能为空）
     */
    private LiveSessionVO currentSession;
    /**
     * 开通时间
     */
    private LocalDateTime openTime;
    private boolean playing;


    private String backgroundColor;

    private String backgroundImage;

    /**
     * 是否是平台直播间
     */
    private Boolean platform;


    private String notice;

    public LiveRoomVO(LiveRoomPO liveRoomPO, LiveSessionService liveSessionService) {
        this.id = liveRoomPO.getId();
        this.merchantId = liveRoomPO.getMerchant().getMerchantId();
        this.enableContact = liveRoomPO.getMerchant().isEnableContact();
        if (liveRoomPO.getMerchant().getData().getMainCategory() != null) {
            this.cateId = liveRoomPO.getMerchant().getData().getMainCategory().getCatId();
        }
        this.data = new LiveRoomDataVO(liveRoomPO.getData());
        this.orderWeight = liveRoomPO.getOrderWeight();
        this.auditStatus = liveRoomPO.getAuditStatus();
        this.reason = liveRoomPO.getReason();
        this.enabled = liveRoomPO.isEnabled();
        LiveSessionPO liveSessionPO = liveRoomPO.currentSession();
        if (liveSessionPO != null && liveSessionService != null) {
            this.currentSession = new LiveSessionVO(liveSessionPO, liveSessionService);
        }
        this.playing = liveRoomPO.isPlaying();
        this.enabled = liveRoomPO.isEnabled();
        this.openTime = liveRoomPO.getOpenTime();
        this.backgroundColor = liveRoomPO.getBackgroundColor();
        this.backgroundImage = liveRoomPO.getBackgroundImage();
        this.platform = liveRoomPO.isPlatform();
    }
}
